<template>
  <div class="home-content">
    <HomeTitle category="账号管理" variety="账号列表" class="title"></HomeTitle>
    <el-row>
      <el-button type="primary" data-status="add" @click="addEdit">新增账号</el-button>
    </el-row>
    <div class="mt20">
      <el-table :data="moduleList" border class="widthp100 cursor">
        <el-table-column prop="name" width="100" label="模块名称" align="center"></el-table-column>
        <el-table-column prop="sort" width="100" label="权重" align="center"></el-table-column>
        <el-table-column prop="url" width="" label="路由" align="center"></el-table-column>
        <el-table-column fixed="right" label="操作" width="180" align="center">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
            <el-button type="text" size="small">编辑</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="新增账号" :visible.sync="dialog.show" width="360px" :center="true" :append-to-body="true">
      <el-form label-width="80px" size="mini">
        <div class="prow10 pb20">
          <div class="mt15">
            <el-input ref="returnCodes" autofocus="autofocus" class="el-gray" name="" placeholder="请输入模块名称"
              v-model="listInfo.name">
              <template slot="prepend" class="bctran">模块名称:</template>
            </el-input>
          </div>
          <div class="mt15">
            <el-input ref="returnCodes" autofocus="autofocus" class="el-gray" name="" placeholder="请输入模块父节点id"
              v-model="listInfo.parentId">
              <template slot="prepend" class="bctran">父节点id:</template>
            </el-input>
          </div>
          <div class="mt15">
            <el-input ref="returnCodes" autofocus="autofocus" class="el-gray" name="" placeholder="请输入模块权重"
              v-model="listInfo.sort">
              <template slot="prepend" class="bctran">权重:</template>
            </el-input>
          </div>
          <div class="mt15">
            <el-input ref="returnCodes" autofocus="autofocus" class="el-gray" name="" placeholder="请输入路由链接"
              v-model="listInfo.url">
              <template slot="prepend" class="bctran">路由:</template>
            </el-input>
          </div>
          <div slot="footer" class="dialog-footer tar">
            <el-button @click="dialog.show = false" size="small">取 消</el-button>
            <el-button type="primary" @click="confirmAddEdit" size="small">确 定</el-button>
          </div>
        </div>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
  import {moduleList} from '@/request/api'; // 导入我们的api接口
  import {addModule} from '@/request/api'; // 导入我们的api接口
  /* import qs from 'qs'; */
  let listInfo={name:'',parentId:'',sort:'',url:''};
  export default {
    name: 'module',
    data: function() {
      return {
        dialog:{show:false},
        currentPage:1,
        listInfo:listInfo,
        params:{limit:10,pagesize:0,parentId:''}
        ,moduleList: []
      }
    },
    mounted: function() {
      let params = this.$route.query; //parms包含传递的所有参数
      console.log(params);
    },
    created:function(){
      let params = this.$route.query;
      console.log(params.parentId);
      this.params.parentId=params.parentId;
      moduleList(this.params).then(res=>{
        console.log(res);
      });
    },
    methods: {
      addEdit: function(e) {
        let status=e.currentTarget.dataset.status;
        console.log(status);
         this.dialog.show=true;
      },
      handleClick(row) {
        console.log(row);
      },
      confirmAddEdit:function(){
        addModule(this.$qs.stringify(this.listInfo)).then(res => {
          console.log(res);
          this.leftMenuTrees = res.data;
        });

      },

    }

  }


</script>

<style>
</style>
